package tinyms.posture.api;

import tornadoj.data.LuceneUtil;
import tornadoj.web.Api;
import tornadoj.web.ApiResult;
import tornadoj.web.Function;
import tornadoj.web.HttpContext;

/**
 *
 * Created by tinyms on 15/10/8.
 */
@Api(name = "com.tinyms.posture")
public class Search {
    @Function(name = "search")
    public Object find(HttpContext context) {
        ApiResult r = new ApiResult();
        r.setSuccess(true);
        String kw = context.param("kw", "");
        int currentPage = context.paramInt("currentPage", 1);
        int pageSize = 20;
        LuceneUtil luceneUtil = new LuceneUtil("");
        r.setData(luceneUtil.search("PosturePicture", kw, currentPage, pageSize, false));
        return r;
    }
}
